#pragma once

#include <sys/epoll.h>
#include <memory>
#include <string>
#include "InetAddr.hpp"
#include "TcpServer.hpp"

// Connetion作为虚基类，派生类Listener等
class Connection
{
public:
    Connection()
    {
    }
    virtual void Recver() = 0;
    virtual void Sender() = 0;
    virtual void Excpeter() = 0;

    void SetEvents(uint32_t events)
    {
        _events = events;
    }
    void SetFd(int fd)
    {
        _fd = fd;
    }
    uint32_t GetEvents()
    {
        return _events;
    }
    int GetFd()
    {
        return _fd;
    }

    ~Connection()
    {
    }

private:
    int _fd;
    std::string _inbuffer;
    std::string _outbuffer;

    // 回指指针
    TcpServer *base;

    // 客户端信息
    InetAddr _client_info;

    // 连接关心的事件
    uint32_t _events;
};